# import socket
# sk=socket.socket(type=socket.SOCK_DGRAM)#udp协议必须写参数，不写默认tcp协议
#
# sk.bind(('127.0.0.1',9001))#绑定端口号
#
# msg,addr=sk.recvfrom(1024)#返回一个元组
# print(msg)
#
# sk.sendto(b'recv',addr)


import socket
sk=socket.socket(type=socket.SOCK_DGRAM)
sk.bind(('127.0.0.1',9001))

msg,addr=sk.recvfrom(1024)
print(msg.decode('utf-8'))
sk.sendto('你好'.encode('utf-8'),addr)














